package com.hotacorp.opencloud.jobservice.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.hotacorp.opencloud.common.commdata.Result;
import com.hotacorp.opencloud.common.log.annotation.LogAnnotation;
import com.hotacorp.opencloud.common.mybatisplus.PageData;
import com.hotacorp.opencloud.jobservice.entity.ScheduleJobLogEntity;
import com.hotacorp.opencloud.jobservice.service.ScheduleJobLogService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;



/**
 * 定时任务日志
 *
 * @author lwg
 * @email liwugang@139.com
 * @date 2020-01-03 12:31:29
 */
@RestController
@Api(tags = "任务日志API")
public class ScheduleJobLogController {
    @Autowired
    private ScheduleJobLogService scheduleJobLogService;

    /**
     * 列表
     */
    @GetMapping(value = "/schedulejoblog/list")
    @PreAuthorize("hasAuthority('jobservice:schedulejoblog:list')")
	@ApiOperation(value = "查询任务执行日志")
    @LogAnnotation(module = "任务")
    public Result<?> list(@RequestParam Map<String, Object> params){
        PageData page = scheduleJobLogService.queryPage(params);

        return Result.succeed("succeed", page);
    }


    /**
     * 信息
     */
    @GetMapping(value = "/schedulejoblog/info/{logId}")
    @PreAuthorize("hasAuthority('jobservice:schedulejoblog:info')")
	@ApiOperation(value = "任务执行日志详情")
    @LogAnnotation(module = "任务")
    public Result<?> info(@PathVariable("logId") Long logId){
		ScheduleJobLogEntity scheduleJobLog = scheduleJobLogService.getById(logId);

        return Result.succeed("succeed", scheduleJobLog);
    }

}
